package com.huc.ctrl;

import com.huc.entity.Order;
import com.huc.event.OrderEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther huc
 * @date 2020/8/24 0024 AM 9:41
 */
@RestController
@RequestMapping("/order")
public class OrderCtrl {
    @Autowired
    ApplicationContext context;

    @GetMapping("/add")
    public Order add(){
        Order order=new Order(1L,"199元特价运动鞋","王二哥",19900,null);
        context.publishEvent(new OrderEvent(this,order));
        return order;
    }
}
